package com.spic.system.api;


import com.spic.common.core.constant.SecurityConstants;
import com.spic.common.core.constant.ServiceNameConstants;
import com.spic.common.core.domain.R;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.system.api.domain.SysDept;
import com.spic.system.api.domain.SysRole;
import com.spic.system.api.domain.SysUser;
import com.spic.system.api.factory.RemoteUserFallbackFactory;
import com.spic.system.api.model.LoginUser;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 用户服务
 *
 * @author ruoyi
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService {
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source   请求来源
     * @return 结果
     */
    @GetMapping("/user/info/{username}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @param source  请求来源
     * @return 结果
     */
    @PostMapping("/user/register")
    public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    @PostMapping("/dept/treeselectList")
    public Object treeselectList(@RequestBody(required = false) SysDept dept);

    @GetMapping("/user/lists/{userId}")
    public R<SysUser> getUserById(@PathVariable("userId") Long userId);

    @GetMapping("/user/list2")
    public R<List<SysUser>> getSysUserByDeptId(@RequestParam("deptId") Long deptId);

    @GetMapping("/role/lists/{roleId}")
    public R<SysRole> getRoleById(@PathVariable("roleId") Long roleId);

    /**
     * 获取部门树Feign
     *
     * @param deptId
     * @return
     */
    @GetMapping("dept/lists/{deptId}")
    public R<SysDept> lists(@PathVariable("deptId") Long deptId);

    @GetMapping("user/getSysUserByDeptIds/{deptIds}")
    public R<List<SysUser>> getSysUserByDeptIds(@PathVariable("deptIds") Long[] deptIds);

    @PostMapping("user/userInfo")
    public R<SysUser> userInfo(@RequestBody(required = false) SysUser sysUser);

    @GetMapping("/dept/map")
    public R<Map<Long, String>> map();

    @GetMapping("user/selectAdminByRoleAndDept")
    public R<List<Map<String, Object>>> selectAdminByRoleAndDept(@RequestParam Map<String, Object> map);

    /**
     * 获取业务流水号
     *
     * @param codeName
     * @return
     */
    @GetMapping(value = "/codeConfig/cur_code")
    public R<String> getCode(@RequestParam("codeName") String codeName);


    @GetMapping("/user/userPost")
    public R<List<Map<String, Object>>> getPostUser();

    @GetMapping("/user/getCacheByUserId")
    public R<Map<Long, String>> getCacheByUserId();

    /**
     * 通过部门id获取部门违章管理员id
     *
     * @param deptId 部门id
     * @return 用户
     */
    @GetMapping("/user/getWzUserId/{deptId}")
    public R<SysUser> getWzUserId(@PathVariable("deptId") String deptId);

    /**
     * 获取参数
     *
     * @param configKey configKey
     * @return configValue
     */
    @GetMapping(value = "/config/configKey/{configKey}")
    public R<String> selectConfigByKey(@PathVariable("configKey") String configKey);

    @PutMapping("/user/updateCid")
    public R<AjaxResult> updateCid(@RequestBody SysUser user);

    /**
     * 新增用户
     */
    @PostMapping("/user/addNoAuth")
    public R<SysUser> addUser(@RequestBody(required = false) SysUser sysUser);

    @GetMapping("/user/getUserListByParentId/{parentDeptId}")
    public R<Long[]> getUserListByParentId(@PathVariable("parentDeptId") Long parentDeptId);


    // 公示公告更新 更新是否过期 不显示了
    @PostMapping("/announceReader/setStateHidden")
    R<Long[]> setStateHidden();

    @GetMapping("/userall/syncuser2all")
    R<AjaxResult> syncuser2all();

    @GetMapping("/userall/filterDirtyData")
    R<AjaxResult> filterUserDirtyData();
}
